﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Imgalib.Utility
{
    /// <summary>
    /// This Class provides some builtin regular expression to work with
    /// </summary>
    public class RegExUtility
    {
        /// <summary>
        /// Determine if provided String literal has special charecter or not
        /// </summary>
        /// <param name="stringToMatch">String literal to match</param>
        /// <returns>result of matching</returns>
        public static Boolean HasSpecialCharacter(String stringToMatch)
        {
            return !Regex.IsMatch(stringToMatch, @"^[a-z A-Z 0-9 \s]+$", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.CultureInvariant);
        }

        /// <summary>
        /// Determine if provided String literal has comma charecter or not
        /// </summary>
        /// <param name="stringToMatch">String literal to match</param>
        /// <returns>result of matching</returns>
        public static Boolean HasComma(String stringToMatch)
        {
            return Regex.IsMatch(stringToMatch, @"^.+[,].+$", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.CultureInvariant);
        }

        /// <summary>
        /// Determine if provided String literal has LF character, CR character and a tab character  charecter or not
        /// </summary>
        /// <param name="stringToMatch">String literal to match</param>
        /// <returns>result of matching</returns>
        public static Boolean HasLineBreaks(String stringToMatch)
        {
            return Regex.IsMatch(stringToMatch, @"^.+[\n\r\t].+$", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.CultureInvariant);
        }
    }
}
